package member2;

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.JButton;

import Member1.Data6;

import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Date;

public class Input extends JPanel {
	private JLabel lblNewLabel;
	private JLabel lblNewLabel_1;
	private JLabel lblNewLabel_2;
	private JLabel lblNewLabel_3;
	private JLabel lblNewLabel_4;
	private JTextField irum;
	private JTextField address;
	private JTextField phone;
	private JTextField email;
	private JTextField age;
	private JButton btnNewButton;
	private JLabel status;

	ArrayList<Data> list;        // 생성자에
	/**
	 * Create the panel.
	 */
	public Input(ArrayList list) {    // 
		this.list = list;    //
		
		setLayout(null);
		add(getLblNewLabel());
		add(getLblNewLabel_1());
		add(getLblNewLabel_2());
		add(getLblNewLabel_3());
		add(getLblNewLabel_4());
		add(getIrum());
		add(getAddress());
		add(getPhone());
		add(getEmail());
		add(getAge());
		add(getBtnNewButton());
		add(getStatus());

	}
	private JLabel getLblNewLabel() {
		if (lblNewLabel == null) {
			lblNewLabel = new JLabel("이름");
			lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);
			lblNewLabel.setBounds(12, 10, 57, 15);
		}
		return lblNewLabel;
	}
	private JLabel getLblNewLabel_1() {
		if (lblNewLabel_1 == null) {
			lblNewLabel_1 = new JLabel("주소");
			lblNewLabel_1.setHorizontalAlignment(SwingConstants.RIGHT);
			lblNewLabel_1.setBounds(12, 35, 57, 15);
		}
		return lblNewLabel_1;
	}
	private JLabel getLblNewLabel_2() {
		if (lblNewLabel_2 == null) {
			lblNewLabel_2 = new JLabel("연락처");
			lblNewLabel_2.setHorizontalAlignment(SwingConstants.RIGHT);
			lblNewLabel_2.setBounds(12, 60, 57, 15);
		}
		return lblNewLabel_2;
	}
	private JLabel getLblNewLabel_3() {
		if (lblNewLabel_3 == null) {
			lblNewLabel_3 = new JLabel("이메일");
			lblNewLabel_3.setHorizontalAlignment(SwingConstants.RIGHT);
			lblNewLabel_3.setBounds(12, 85, 57, 15);
		}
		return lblNewLabel_3;
	}
	private JLabel getLblNewLabel_4() {
		if (lblNewLabel_4 == null) {
			lblNewLabel_4 = new JLabel("나이");
			lblNewLabel_4.setHorizontalAlignment(SwingConstants.RIGHT);
			lblNewLabel_4.setBounds(12, 110, 57, 15);
		}
		return lblNewLabel_4;
	}
	private JTextField getIrum() {
		if (irum == null) {
			irum = new JTextField();
			irum.setBounds(79, 7, 116, 21);
			irum.setColumns(10);
		}
		return irum;
	}
	private JTextField getAddress() {
		if (address == null) {
			address = new JTextField();
			address.setBounds(79, 32, 116, 21);
			address.setColumns(10);
		}
		return address;
	}
	private JTextField getPhone() {
		if (phone == null) {
			phone = new JTextField();
			phone.setBounds(79, 57, 116, 21);
			phone.setColumns(10);
		}
		return phone;
	}
	private JTextField getEmail() {
		if (email == null) {
			email = new JTextField();
			email.setBounds(79, 82, 116, 21);
			email.setColumns(10);
		}
		return email;
	}
	private JTextField getAge() {
		if (age == null) {
			age = new JTextField();
			age.setBounds(79, 107, 116, 21);
			age.setColumns(10);
		}
		return age;
	}
	private JButton getBtnNewButton() {
		if (btnNewButton == null) {
			btnNewButton = new JButton("저장");
			btnNewButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					String n = irum.getText();
					String a = address.getText();
					String p = phone.getText();
					String e = email.getText();
					int   ag = Integer.parseInt(age.getText());
					Date   d = new Date();
					
					Data data = new Data(n, a, p, e, ag, d);
					list.add(data);
					
				}
			});
			btnNewButton.setBounds(79, 138, 63, 23);
		}
		return btnNewButton;
	}
	private JLabel getStatus() {
		if (status == null) {
			status = new JLabel("데이터 값을 입력하세요");
			status.setOpaque(true);
			status.setBackground(Color.GREEN);
			status.setBounds(12, 275, 426, 15);
		}
		return status;
	}
}
